<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="/WEB-INF/jsp/common/init.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<jsp:include page="/WEB-INF/jsp/common/common.jsp" />
	<jsp:include page="/WEB-INF/jsp_lib/validate.jsp" />
	<script type="text/javascript" src="${path}/style_lib/upload/swfupload/swfupload.js"></script>
	<%-- <script type="text/javascript" src="${path}/style_lib/upload/swfupload/swfupload.queue.js"></script> --%>
	<script type="text/javascript" src="${path}/style_lib/upload/swfupload/fileprogress.js"></script>
	<script type="text/javascript" src="${path}/style_lib/upload/swfupload/handlers.js"></script>
	<script type="text/javascript">
	$(function() {
		$("#form1").validate({
			ignore:[],
			rules : {
				'file_id' : {
					required : true
				},
				'true_code' : {
					required : true,
					minlength:9,
					maxlength:9,
					remote:{
						type:"POST",
	               		url	:"${path}/ix/seal/news/apply/unique_code.htm?seal_new_id=${sealNew._id}"   
					}
				},
				'save_user_id' : {
					required : true
				}
			},
			messages:{
				'file_id' :{required:'请上传印模图片'},
				true_code:{remote :"该编码已存在，请重新输入！"}
			}
		});
	});
	function uploadSuccess(file, serverData) {
	        var end = $.parseJSON(serverData);
	        $("#main_pic").html("<img src='${path}/img/"+end.file_id+".htm?mh=150&mw=150'/>");
			$("input[name='file_id']").val(end.file_id);
	}
    $(function(){
          var upload1 = new SWFUpload({
		
		// Backend Settings
		upload_url : "${path}/swfupload.htm",
		//post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
		// File Upload Settings
		file_size_limit : "1200 MB",	// 100MB
		file_types : "*.gif;*.jpg;*.jpeg;*.bmp;*.png",
		file_upload_limit : 1,

		// Event Handler Settings (all my handlers are in the Handler.js file)
		swfupload_preload_handler : preLoad,
		swfupload_load_failed_handler : loadFailed,
		file_dialog_start_handler : fileDialogStart, 
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,

		// Button Settings
		button_placeholder_id : "filePicker",
		button_width: 80,
		button_height: 22,
		button_text:"选择图片",
		
		// Flash Settings
		flash_url : "${path}/style_lib/upload/swfupload/swfupload.swf",
		flash9_url : "${path}/style_lib/upload/swfupload/swfupload_fp9.swf",
	

		custom_settings : {
			progressTarget : "fsUploadProgress1"//,
			//cancelButtonId : "btnCancel1"
		},
		
		// Debug Settings
		debug: false
	});
	
    });
	
	function pass() {
		$("input[name='flag']").val("通过");
		$("#form1").submit();
	}
	function unpass() {
		$("input[name='flag']").val("不通过");
		
		$("#form1").submit();
	}
	</script>
</head>
<body>
	<jsp:include page="/WEB-INF/jsp_lib/tip.jsp" />
	<!-- 内容 -->
	<div>
		<form method="post" action="${path}/ix/seal/news/engraving_back/back.htm" id="form1">
			<input type="hidden" name="sealnew_id" value="${sealNew._id}" />
			<input type="hidden" name="file_id" />
			<input type="hidden" name="flag" value="" />
			<h2>
				<div>
					印章登记
				</div>
			</h2>
			<table width="100%" class="lindex">
				<tr>
					<th align="right" >
						印章种类:
					</th>
					<td align="left">
						${sealType.name} 
					</td>
					<th align="right">
						印章类型:
					</th>
					<td align="left">
						${sealTypeConfig.name}
					</td>
				</tr>
				<tr>
					<th align="right">
						刻章字样:
					</th>
					<td align="left">
						${sealNew.title}
					</td>
						<th align="right">
						刻章原因:
					</th>
					<td align="left">
						${sealNew.desc_s}
					</td>
				</tr>
				<tr>
					<th align="right">
						刻章厂:
					</th>
					<td align="left" colspan="3">
						${sealNew.factory}
					</td>
				</tr>
				<tr>
				<th align="right">
						刻章厂联系人:
					</th>
					<td align="left">
						${sealNew.factory_linkman}
					</td>
					<th align="right">
						刻章厂联系人电话:
					</th>
					<td align="left">
						${sealNew.factory_mobile}
					</td>
				</tr>
				<tr>
					<th align="right">
						实物编号：
					</th>
					<td align="left" >
						<input name="true_code" value="${sealNew.true_code}" type="text" maxlength="32" />
					</td>
					<th align="right">
						 保管人员：
					</th>
					<td align="left" colspan="3">
						<select name="save_user_id">
						<option value="">--请选择--</option>
							<c:forEach items="${userlist}" var="v">
								<option value="${v._id}">${v.uname}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<th align="right">
						印模上传：
					</th>
					<td align="left" colspan="3">
						<div id="main_pic"></div>
						<div id="uploader-demo">
						    <!--用来存放item-->
						    <div id="fileList" class="uploader-list"></div>
						    <div id="filePicker"></div>
						</div>
						<label for="file_id" class="error"></label>
					</td>
				</tr>
				<tr>
					<th align="right">备注：</th>
					<td align="left" colspan="3">
						<textarea maxlength="150" name="note" rows="5" cols="50" maxlength="255"></textarea>
					</td>
				</tr>
				
			</table>
			<div class="options">
				<a href="javascript:pass();" class="asave">
					【通过】
				</a>
				<a href="javascript:unpass();" class="asave">
					【不通过】
				</a>
				<a href="javascript:goBack();" class="aback">
					【返回】
				</a>
			</div>
		</form>
	</div>
</body>
</html>